package com.vichat.common.rudp;

public class ByteUtil {

    public static int byte2int(byte[] indata, int datalen) {
        int mask = 0xff;
        int temp = 0;
        int n = 0;
        for (int i = 0; i < datalen; i++) {
            temp = (indata[i] & mask) << 8 * i;
            n |= temp;
        }
        return n;
    }


    public static byte[] int2byte(int iSource, int iArrayLen) {
        byte[] bLocalArr = new byte[iArrayLen];
        for (int i = 0; (i < 4) && (i < iArrayLen); i++) {
            bLocalArr[i] = (byte) (iSource >> 8 * i & 0xFF);
        }
        return bLocalArr;
    }
}
